<%@page pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-cmn">
<head>
    <meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
    <title>Document</title>
    <%@include file="/WEB-INF/jsp/header.jsp"%>
    <style type="text/css">
        #addTable tr{
            height: 60px;
            vertical-align: top;
        }
    </style>
</head>
<body>


</div>
    <div class="container-fluid">
        <div class="panel panel-primary ">
            <div class="panel-heading">
                <h3 class="panel-title">医护人员登记<span style="font-size: 12px" class="pull-right">人员工号:${woJubnum}</span></h3>

            </div>
            <div class="panel-body">
                <form action="${ctx}/doc/add" method="post" id="addForm" enctype="multipart/form-data">
                    <input type="hidden" value="${woJubnum}" name="woJubnum" />
                    <table border="0" id="addTable">
                        <tr>
                            <td>

                                <label class="layui-form-label">姓名:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="woName" autocomplete="off" class="layui-input">
                                    <span style="color: red;"></span>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">角色:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <select name="roleId" id="" class="layui-select" style="width: 186px">
                                        <option value="-1">==请选择==</option>
                                        <c:forEach items="${role}" var="r">
                                            <option value="${r.roleId}">${r.roleName}</option>
                                        </c:forEach>
                                    </select><br/>
                                    <span style="color:red;"></span>
                                </div>
                            </td>
                            <td>
                                <label style="width: 100px;" class="layui-form-label">工作年限:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="number" name="workLife" autocomplete="off" class="layui-input">
                                    <span style="color: red"></span>
                                </div>
                            </td>
                            <td rowspan="7">
                                <input id="myfile" accept="image/png,image/jpeg" name="myfile" type="file" data-show-caption="true">
                                <p class="help-block">支持jpg、jpeg、png格式，大小不超过2.0M</p>
                                <span style="color: red;" id="file"></span>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label class="layui-form-label">学历:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="woEducation" autocomplete="off" class="layui-input">
                                    <span style="color: red;"></span>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">性别:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <select name="woSex"  class="layui-select" style="width: 186px">
                                        <option value="0">男</option>
                                        <option value="1">女</option>
                                    </select><br/>
                                    <span style="color: red;"></span>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">民族:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="woNation" class="layui-input"  />
                                    <span style="color:red;"></span>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label style="width: 100px;" class="layui-form-label">身份证号:</label>
                            </td>
                            <td colspan="3">
                                <div class="layui-input-inline">
                                    <input type="text" name="woIdentityCard" onblur="blur()" class="layui-input"  style="width: 472px;" />
                                    <span style="color: red;"></span>
                                </div>
                            </td>

                            <td>
                                <label style="width: 100px;" class="layui-form-label">出生日期:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" name="woBirthday" />
                                    <span style="color: red;"></span>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label style="width: 100px" class="layui-form-label">户口住址:</label>
                            </td>
                            <td colspan="3">
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" name="woResidence" style="width:472px;"  />
                                    <span style="color: red;"></span>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">国籍:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="woNationality" class="layui-input"  />
                                    <span style="color:red;"></span>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label style="width: 100px" class="layui-form-label">现住址地:</label>
                            </td>
                            <td colspan="3">
                                <div class="layui-input-inline">
                                    <input type="text" name="woAddress" class="layui-input" style="width: 472px;"  />
                                    <span style="color: red;"></span>
                                </div>
                            </td>
                            <td>
                                <label style="width:100px;" class="layui-form-label">婚姻状况:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <select name="woMaritalstate"  class="layui-select" style="width: 185px">
                                        <option value="0">已婚</option>
                                        <option value="1">未婚</option>
                                    </select>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label style="width:100px;" class="layui-form-label">操作人员:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="" value="${sessionScope.loginUser.woName}" disabled="disabled" class="layui-input" />
                                </div>
                            </td>
                            <td>
                                <label style="width:100px;" class="layui-form-label">联系电话:</label>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="woPhone" style="" value=""  class="layui-input" />
                                    <span style="color: red;"></span>
                                </div>
                            </td>
                            <c:if test="${not empty bool}" var="flag">
                                <td>
                                    <label class="layui-form-label">科室:</label>
                                </td>
                                <td>
                                    <div class="layui-input-inline">
                                        <select name="divCode" style="width: 185px" id="divCode" class="layui-select">
                                            <option value="-1">==请选择==</option>
                                        </select><br/>
                                        <span style="color:red;"></span>
                                    </div>
                                </td>
                            </c:if>

                        </tr>
                        <tr>
                            <td>
                                <label style="width:100px;" class="layui-form-label">个人说明:</label>
                            </td>
                            <td colspan="5">
                                <textarea class="layui-textarea" name="woPerExplain" rows="8" cols="20" ></textarea>
                            </td>
                        </tr>

                        <tr style="text-align: center">
                            <td colspan="7" class="" style="width: 300px;">
                                <div style="height: 10px;"></div>
                                <div class="text-cneter">
                                    <button type="button" id="addSubmit" class="btn btn-info">提交</button>&nbsp;&nbsp;&nbsp;&nbsp;
                                    <button type="button" onclick="reset()" class="btn btn-primary">重置</button>
                                </div>
                            </td>
                        </tr>
                    </table>
                    <input type="hidden" name="woCeavatar" id="woPic" />
                    <c:if test="${not flag}">
                        <input type="hidden" value="${division.divCode}" name="divCode" />
                    </c:if>
                </form>
            </div>
        </div>
    </div>
    <%@include file="/WEB-INF/jsp/footer.jsp"%>
<script type="text/javascript">
    function reset() {
        $("#addTable input").val("");
    }
    $("#addSubmit").on("click",function () {
        var woName = $("#addTable [name=woName]").val();//姓名
        var roleId = $("#addTable [name=roleId]").val();//角色
        var workLife = $("#addTable [name=workLife]").val();//工作年限
        var woEducation = $("#addTable [name=woEducation]").val();//学历
        var woNation = $("#addTable [name=woNation]").val();//民族
        var woIdentityCard = $("#addTable [name=woIdentityCard]").val();//身份证
        var woBirthday = $("#addTable [name=woBirthday]").val();//生日
        var woResidence = $("#addTable [name=woResidence]").val();//户口住址
        var woNationality = $("#addTable [name=woNationality]").val();//国籍
        var woAddress = $("#addTable [name=woAddress]").val();//现住址
        var phone = $("#addTable [name=woPhone]").val();//电话
        var woCeavatar = $("[name=woCeavatar]").val();//证件
        var divCode = $("#addTable [name=divCode]").val();//科室编号

        if(woName==null || woName==''){
            $("#addTable [name=woName]").siblings("span").html("姓名不可为空!")
        } else if(woName.length<2){
            $("#addTable [name=woName]").siblings("span").html("姓名长度不得小于二!")
        } else if(roleId==-1){
            $("#addTable [name=roleId]").siblings("span").html("角色没选中哦!");
        } else if(workLife<0){
            $("#addTable [name=workLife]").siblings("span").html("请输入正确的操作!");
        } else if(workLife==null || workLife ==''){
            $("#addTable [name=workLife]").siblings("span").html("请输入工作年限!");
        } else if(woEducation==null || woEducation==''){
            $("#addTable [name=woEducation]").siblings("span").html("学历不可以为空!");
        } else if(woNation==null||woNation==''){
            $("#addTable [name=woNation]").siblings("span").html("民族不可以为空!");
        } else if(woIdentityCard==null || woIdentityCard==''){
            $("#addTable [name=woIdentityCard]").siblings("span").html("身份证不可以为空!");
        } else if(woIdentityCard.length!=18){
            $("#addTable [name=woIdentityCard]").siblings("span").html("身份证不正确!");
        } else if(woBirthday==null || woBirthday==''){
            $("#addTable [name=woBirthday]").siblings("span").html("生日不能为空!");
        } else if(woResidence==null || woResidence==''){
            $("#addTable [name=woResidence]").siblings("span").html("户口住址不能为空!");
        } else if(woNationality==null || woNationality==''){
            $("#addTable [name=woNationality]").siblings("span").html("国籍不能为空!");
        } else if(woAddress=null||woAddress==''){
            $("#addTable [name=woAddress]").siblings("span").html("现住址不能为空!");
        } else if(phone.length!=11){
            $("#addTable [name=woPhone]").siblings("span").html("电话长度为11位!");
        } else if(phone==null || phone==''){
            $("#addTable [name=woPhone]").siblings("span").html("电话不能为空!");
        } else if(woCeavatar==null||woCeavatar==''){
            $("#file").html("请选择证件照!")
        } else if(divCode==-1){
            $("#addTable [name=divCode]").siblings("span").html("请选择科室!")
        } else{
            $("#addForm").submit();
        }
        //获取焦点
        $("#addTable input").focus(function () {
            $(this).siblings("span").html("");
        });
        $("#addTable [name=roleId]").change(function () {
            $(this).siblings("span").html("");
        });
        $("#woPic").change(function () {
            $("#file").html("");
        })

    })
    /*function blur() {
        alert("1")
        var nian = woIdentityCard.substring(6,10);
        var yue = woIdentityCard.substring(10,12);
        var ri = woIdentityCard.substring(12,14);
        var bir = nian+"-"+yue+"-"+ri;
        if(woIdentityCard!=null && woIdentityCard!='' && woIdentityCard.length==18){
            $("#addTable [name=woBirthday]").val(bir)
        }
    }*/
    function initFileInput(ctrlName,uploadUrl) {
        var control = $('#' + ctrlName);
        control.fileinput({
            language: 'zh', //设置语言
            uploadUrl: uploadUrl,  //上传地址
            showUpload: false, //是否显示上传按钮
            showRemove:true,
            dropZoneEnabled: false,
            autoReplace:true,
            showCaption: true,//是否显示标题
            dropZoneEnabled:true,//是否显示拖拽
            textEncodingOverride:"UTF-8",
            enctype: 'multipart/form-data',
            allowedPreviewTypes: ['image'],
            allowedFileTypes: ['image'],
            allowedFileExtensions:  ['jpg', 'png','jpeg'],
            dropZoneTitle:"请上传证件照",
        }).on("filebatchselected", function(event, files) {
            $(this).fileinput("upload");
        }).on("fileuploaded", function(event, data, previewId, index) {
                $("#woPic").val(data.response)
        });
    }

    $(function () {
        var path="${prc}/doc/uploadPic";
        initFileInput("myfile",path);

    });
    //搜索日期插件
    $(function () {
        laydate.render({
            elem:'[name=woBirthday]'
        })
    });
    if(${bool!=null}){
        $.ajax({
            url:ctx+"/doc/searchDivision",
            type:"post",
            dataType:"json",
            success:function (arr) {
                $.each(arr,function () {
                    var $opt = $("<option/>");
                    $opt.val(this.divCode);
                    $opt.html(this.divName);
                    $opt.appendTo("#divCode");
                });
            }
        })
    }
</script>
</body>
</html>
